﻿using strange.extensions.context.impl;
using strange.extensions.context.api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameContext : MVCSContext
{
    //构造函数
    public GameContext(MonoBehaviour view, bool autoMapping) : base(view, autoMapping)
    {

    }

    /// <summary>
    ///  事件绑定
    /// </summary>
    protected override void mapBindings()
    {
        //inject Model的绑定
        injectionBinder.Bind<IntegralModel>().To<IntegralModel>().ToSingleton();  //游戏场景中只存在一份，单例
        injectionBinder.Bind<CardModel>().To<CardModel>().ToSingleton();
        injectionBinder.Bind<RoundModel>().To<RoundModel>().ToSingleton();

        //command  Controller 和事件的binder
        commandBinder.Bind(CommandEvent.ChangeMultiple).To<ChangeMultipleCommand>();
        commandBinder.Bind(CommandEvent.RequestPlayGame).To<RequestDealCommand>();
        commandBinder.Bind(CommandEvent.GrabLandlord).To<GrabAndDisGrabCommand>();
        commandBinder.Bind(CommandEvent.PlayCard).To<PlayCardCommand>();
        commandBinder.Bind(CommandEvent.PassCard).To<PassCardCommand>();
        commandBinder.Bind(CommandEvent.GameOver).To<GameOverCommand>();
        commandBinder.Bind(CommandEvent.RequestUpdate).To<RequestUpdateCommand>();
        commandBinder.Bind(CommandEvent.UpdateGameOver).To<UpdateGameOverCommand>();
        //view    mediator与view的 binder
        //表示View与对应的mediator进行绑定
        mediationBinder.Bind<StartView>().To<StartMediator>();
        mediationBinder.Bind<InteractionView>().To<InteractionMediator>();
        mediationBinder.Bind<CharacterView>().To<CharacterMediator>();
        mediationBinder.Bind<GameOverView>().To<GameOverMediator>();

        //主界面的调用一次就可以了，以后不不会在执行。
        commandBinder.Bind(ContextEvent.START).To<StartCommand>().Once();
    }
}
